'use strict';
exports.main = async (event, context) => {
	const db = uniCloud.database()
	const collection = db.collection('user')
	const collection_lianjie = db.collection('lianjie_data')
	switch (event.action) {
		case 'add':
			return await collection.add(event.data)
		case 'add_lianjie':
			return await collection_lianjie.add(event.data)
		case 'delete':
			return await collection.doc(event._id).remove()
		case 'delete_lianjie':
			return await collection_lianjie.doc(event._id).remove()
		case 'update':
			return await collection.doc(event._id).update(event.data)
		case 'update_lianjie':
			return await collection_lianjie.doc(event._id).update(event.data)
		case 'get':
			return await collection.get()
		case 'get_lianjie':
			return await collection_lianjie.get()
		default:
			return 'Invalid action'
	}
}